/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : structs_internal
	/// </summary>
	public class LogicHeartbeatPOD : IPOD 
    {
        public readonly static Func<LogicHeartbeatPOD> FACTORY = () => new LogicHeartbeatPOD();
		public static Func<LogicHeartbeatPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public string serverId;
		/// <summary>
        /// 
        /// </summary>
		public string ip;
		/// <summary>
        /// 
        /// </summary>
		public int port;
		/// <summary>
        /// 
        /// </summary>
		public long time;
		/// <summary>
        /// 
        /// </summary>
		public int levelCount;
		/// <summary>
        /// 
        /// </summary>
		public int battleCount;
		/// <summary>
        /// 
        /// </summary>
		public int playerCount;
		/// <summary>
        /// 强制选择此服务器, 用于开发阶段
        /// </summary>
		public bool forceSelect;
		
		
		
		/*-- constructors --*/
		public LogicHeartbeatPOD() {}
		public LogicHeartbeatPOD(string serverId, string ip, int port, long time, int levelCount, int battleCount, int playerCount, bool forceSelect) {
			this.serverId = serverId;
			this.ip = ip;
			this.port = port;
			this.time = time;
			this.levelCount = levelCount;
			this.battleCount = battleCount;
			this.playerCount = playerCount;
			this.forceSelect = forceSelect;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_string(serverId);
            _out.Write_string(ip);
            _out.Write_int(port);
            _out.Write_long(time);
            _out.Write_int(levelCount);
            _out.Write_int(battleCount);
            _out.Write_int(playerCount);
            _out.Write_boolean(forceSelect);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            serverId = _in.Read_string();
            if(!_in.HasRemaining()) return;
            ip = _in.Read_string();
            if(!_in.HasRemaining()) return;
            port = _in.Read_int();
            if(!_in.HasRemaining()) return;
            time = _in.Read_long();
            if(!_in.HasRemaining()) return;
            levelCount = _in.Read_int();
            if(!_in.HasRemaining()) return;
            battleCount = _in.Read_int();
            if(!_in.HasRemaining()) return;
            playerCount = _in.Read_int();
            if(!_in.HasRemaining()) return;
            forceSelect = _in.Read_boolean();
        }
		
		public LogicHeartbeatPOD Clone() {
            LogicHeartbeatPOD o = DynamicFactory();
            o.serverId = serverId;
            o.ip = ip;
            o.port = port;
            o.time = time;
            o.levelCount = levelCount;
            o.battleCount = battleCount;
            o.playerCount = playerCount;
            o.forceSelect = forceSelect;
            return o;
        }
        
        public void Clear() {
            serverId = default;
            ip = default;
            port = default;
            time = default;
            levelCount = default;
            battleCount = default;
            playerCount = default;
            forceSelect = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "LogicHeartbeatPOD [";
			str += "serverId=";
			str += serverId;
			str += ", ip=";
			str += ip;
			str += ", port=";
			str += port;
			str += ", time=";
			str += time;
			str += ", levelCount=";
			str += levelCount;
			str += ", battleCount=";
			str += battleCount;
			str += ", playerCount=";
			str += playerCount;
			str += ", forceSelect=";
			str += forceSelect;
			str += "]";
			return str;
		}
		
	}
}